<template>
  <div>
    <form action="">
      姓名: <input type="text"  v-model="user.name"> <br>
      年龄: <input type="text"  v-model="user.age"> <br>
      工资: <input type="text"  v-model="user.salary"> <br>
      个人简介: <input type="text"  v-model="user.des"> <br>
      <input type="button" value="保存用户" @click="saveUser">
      <input type="button" value="取消" @click="$router.push({name:'User'})">
    </form>
  </div>
</template>

<script>
export default {
  name: "UserAdd",
  data(){
    return {
      user :{},
    }
  },
  methods:{
    saveUser(){//1.获取用户输入信息  2.发送axios请求请求后端接口 3.切换路由
      this.$http.post("http://localhost:8990/saveOrUpdate",this.user).then(res=>{
        this.$router.push({name:'User'});
      });
    }
  }
}
</script>

<style scoped>

</style>
